/*
 * @Descripttion : 月 选择器
 * @Versions     : 0.1
 * @Author       : foxui team
 * @Date         : 2022-03-05 18:23:01
 * @LastEditors  : QianFox Team
 * @LastEditTime : 2022-06-07 09:34:46
 */

import { Picker } from './picker';

function Pickermonth() {
    Picker.call(this);
    this.FILL_INPUT_HANDLE = '.foxui-month-picker .foxui-month-table .available';
    this.JUMP_YEAR_HANDLE = '.foxui-month-picker .foxui-picker-body__month .foxui-picker-header .year';
    this.JUMP_MONTH_HANDLE = '.foxui-month-picker .foxui-picker-body__year .foxui-picker-content .available';
    // 当前组件使用
    this.HANDLE = '.foxui-month-picker .foxui-picker-handle:not(.is-disabled)';
}

Object.setPrototypeOf(Pickermonth.prototype, Picker.prototype);

Pickermonth.prototype._init = function () {
    this._bindToggle();
    this._bindFillInput();
    this._bindJumpYear();
    this._bindJumpMonth();
};

Pickermonth.prototype._topHtml = function () {
    return '';
};

Pickermonth.prototype._bodyHtml = function (handle) {
    let inputValue = $(handle).find('input').val(),
        dateArr = [];
    if (inputValue) {
        dateArr = inputValue.split('-');
    }

    let bodyYearHtml = this._bodyYearHtml({ inputValue, year: dateArr[0] }, true);
    let bodyMonthHtml = this._bodyMonthHtml({ inputValue, year: dateArr[0], month: dateArr[1] });

    return bodyYearHtml + bodyMonthHtml;
};

Pickermonth.prototype._bottomHtml = function () {
    return '';
};

let pickermonth = new Pickermonth();

export { pickermonth };
